package pers.karl.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author karl
 * @description: ${description}
 * @create 2019-01-20 16:38
 */
@Controller
public class AnnotationController {

    @RequestMapping("/annotation.action")
    public ModelAndView a(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("msg","I'm annotation controller");
        mv.setViewName("WEB-INF/pages/test.jsp");
        return mv;
    }

    @RequestMapping("request")
    public void request(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("msg","request");
        request.getRequestDispatcher("WEB-INF/pages/test.jsp").forward(request,response);
    }
}
